# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=py3-murmurhash
pkgver=1.0.10
pkgrel=1
pkgdesc="Cython bindings for MurmurHash2"
url="https://github.com/explosion/murmurhash"
arch="all"
license="MIT"
makedepends="
	cython
	py3-gpep517
	py3-setuptools
	py3-wheel
	python3-dev
	"
checkdepends="py3-pytest py3-mmh3"
subpackages="$pkgname-doc $pkgname-pyc"
source="murmurhash-$pkgver.tar.gz::https://github.com/explosion/murmurhash/archive/v$pkgver.tar.gz"
builddir="$srcdir/murmurhash-$pkgver"

# results differ on big endian:
# https://github.com/explosion/murmurhash/issues/26
case "$CARCH" in
s390x) options="!check" ;;
esac

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl

	# otherwise pytest picks up the local one,
	# which doesn't have the native shared library and fails
	mv murmurhash murmurhash-off

	.testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl

	rm -r "$pkgdir"/usr/lib/python3*/site-packages/murmurhash/tests/

	install -Dm644 README.md -t "$pkgdir"/usr/share/doc/$pkgname
}

sha512sums="
89741de10f265e89025d19375be1482619f0aba1c0122460a390481fb4a709bb29f623ee35870c1caaf33524d3646237017c37fb13050ae7824609a331f52a65  murmurhash-1.0.10.tar.gz
"
